package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.info.domain.FhInfoUserinterest;
import com.ruoyi.info.service.IFhInfoUserinterestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 用户兴趣点Controller
 * 
 * @author ruoyi
 * @date 2024-11-09
 */
@RestController
@RequestMapping("/info/userinterest")
public class FhInfoUserinterestController extends BaseController
{
    @Autowired
    private IFhInfoUserinterestService fhInfoUserinterestService;

    /**
     * 查询用户兴趣点列表
     */
    @PreAuthorize("@ss.hasPermi('info:userinterest:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhInfoUserinterest fhInfoUserinterest)
    {
        startPage();
        List<FhInfoUserinterest> list = fhInfoUserinterestService.selectFhInfoUserinterestList(fhInfoUserinterest);
        return getDataTable(list);
    }

    /**
     * 导出用户兴趣点列表
     */
    @PreAuthorize("@ss.hasPermi('info:userinterest:export')")
    @Log(title = "用户兴趣点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhInfoUserinterest fhInfoUserinterest) throws IOException {
        List<FhInfoUserinterest> list = fhInfoUserinterestService.selectFhInfoUserinterestList(fhInfoUserinterest);
        ExcelUtil<FhInfoUserinterest> util = new ExcelUtil<FhInfoUserinterest>(FhInfoUserinterest.class);
        util.exportExcel(response, list, "用户兴趣点数据");
    }

    /**
     * 获取用户兴趣点详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:userinterest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhInfoUserinterestService.selectFhInfoUserinterestById(id));
    }

    /**
     * 新增用户兴趣点
     */
    @PreAuthorize("@ss.hasPermi('info:userinterest:add')")
    @Log(title = "用户兴趣点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhInfoUserinterest fhInfoUserinterest)
    {
        return toAjax(fhInfoUserinterestService.insertFhInfoUserinterest(fhInfoUserinterest));
    }

    /**
     * 修改用户兴趣点
     */
    @PreAuthorize("@ss.hasPermi('info:userinterest:edit')")
    @Log(title = "用户兴趣点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhInfoUserinterest fhInfoUserinterest)
    {
        return toAjax(fhInfoUserinterestService.updateFhInfoUserinterest(fhInfoUserinterest));
    }

    /**
     * 删除用户兴趣点
     */
    @PreAuthorize("@ss.hasPermi('info:userinterest:remove')")
    @Log(title = "用户兴趣点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhInfoUserinterestService.deleteFhInfoUserinterestByIds(ids));
    }
}
